<script>
	import {
		getToken
	} from '@/utils/auth'

	import {
		mapActions,
	} from 'vuex'
	import storage from '@/utils/storage'
	export default {
		onLaunch: function() {
			this.initApp()
		},
		computed: {},
		methods: {
			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()
				// 检查用户登录状态
				//#ifdef H5
				this.checkLogin()
				//#endif
			},
			initConfig() {
				//加载配置档到store
				// if (uni.getStorage('selectedArea')) {
				// 	this.initAreaConfig(uni.getStorage('selectedArea'))
				// } else {
				// 	this.initAreaConfig(this.$store.state.config.totalConfig.defaultArea)
				// }
				if (storage.get('selectedArea')) {
					this.initAreaConfig(storage.get('selectedArea'))
				} else {
					this.initAreaConfig(this.$store.state.config.totalConfig.defaultArea)
				}
			},
			...mapActions(['initAreaConfig']),
			checkLogin() {
				if (!getToken()) {
					this.$tab.reLaunch('/pages/login')
				}
			}
		},
	}
</script>

<style lang="scss">
	@import '@/static/scss/index.scss';
</style>
